home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ahoy 1986 February
/
Ahoy_Magazine_86-02_1986_Double_L.d64
/
making change
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
501b
|
16 lines
0 rem << cd26-1a >>
1 rem commodare #22-1 :
2 rem making change
3 rem solution by jim speers
4 rem
100 input"enter amount: $";t:t%=t*100+.5:ift%>1000then100
110 input"enter # of coins:";c%:x%=t%-c%:ifx%<0then160
120 y%=x%/4:d%=x%-4*y%:y%=y%-2*d%:ify%<0then160
130 q%=y%/6:n%=y%-6*q%:p%=c%-q%-d%-n%:ifp%<0then160
140 z%=q%:z$="quarter":gosub170:z%=d%:z$="dime":gosub170
150 z%=n%:z$="nickel":gosub170:z%=p%:z$="penny":gosub170:end
160 print"no solution possible":end
170 printz%;z$;:ifz$="penny"andz%<>1thenprint"[157]ies":return
180 ifz%<>1thenprint"s":return
190 print:return